<template>
  <div class="search-all">
    <div class="search-stycon">
      <span>模块样式:</span>
      <div class="search-style">
        <div
          v-for="(item, idx) in searchArr"
          :key="idx"
          :class="[nowId === item.id ? 'active':'', 'search-style-item']"
          :style="item.searchItem"
          @click="activeNowIdx(item.id)"
        ></div>
      </div>
    </div>
    <div class="search-con">
      <span>搜索提示:</span>
      <input type="text" v-model="placeholder" />
    </div>
    <div class="search-con">
      <span>关键词:</span>
      <input type="text" v-model="mainKey" class="mainKey" />
      <div class="add-tag">
        <span>添加</span>
      </div>
    </div>
    <div class="addcon">
      <div class="search-itemtag">
        <span>
          关键词关键
          <i class="el-icon-close"></i>
        </span>
      </div>
      <div class="search-itemtag">
        <span>
          关键词关键
          <i class="el-icon-close"></i>
        </span>
      </div>
      <div class="search-itemtag">
        <span>
          关键词关键
          <i class="el-icon-close"></i>
        </span>
      </div>
      <div class="search-itemtag">
        <span>
          关键词关键
          <i class="el-icon-close"></i>
        </span>
      </div>
    </div>
    <div class="search-con">
      <span>跳转:</span>
      <input type="text" v-model="goUrl" class="mainKey" />
      <div class="add-tag">
        <span>选择跳转</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ['nowComIdx'],
  watch: {
    // 设置搜索栏提示内容
    placeholder: function(val) {
      this.$store.commit('search/SET_PLC', val);
    },
    // 设置跳转链接
    goUrl: function(val) {
      this.$store.commit('search/SET_GOURL', val);
    },
    // 设置关键词
    mainKey: function(val) {
      this.$store.commit('search/SET_MAINKEY', val);
    }
  },
  data() {
    return {
      nowId: 0,
      placeholder: "",
      mainKey: "",
      goUrl: "",
      PageAll: [],
      searchArr: [
        {
          id: 1,
          searchItem: {
            borderRadius: "14px",
            border: "1px solid rgba(224,225,232,1)"
          }
        },
        {
          id: 2,
          searchItem: {
            borderRadius: "1px",
            border: "1px solid rgba(224,225,232,1)"
          }
        },
        {
          id: 3,
          searchItem: {
            background: "rgba(0,0,0,.05)",
            borderRadius: "14px"
          }
        },
        {
          id: 4,
          searchItem: {
            background: "rgba(0,0,0,0.05)",
            borderRadius: "3px"
          }
        }
      ]
    };
  },
  methods: {
    // 设置选中样式
    activeNowIdx(id) {
      this.nowId = id;
      this.$store.commit('search/SET_STYLE', id);
      this.$store.dispatch('apply/PageJSONUpData');
    }
  }
};
</script>
<style lang="scss" scoped>
@import "./diyset.scss";
.search-all {
  width: 100%;
  height: 100%;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  .search-style {
    width: 220px;
    height: auto;
    margin-top: -10px;
    .search-style-item {
      width: 100%;
      height: 28px;
      margin-top: 10px;
      background: rgba(255, 255, 255, 1);
      border-radius: 14px;
      border: 1px solid rgba(224, 225, 232, 1);
    }
    .search-style-item.active {
      border-radius: 1px;
      border:1px solid rgba(0,138,255,1) !important;
    }
  }
  .search-stycon {
    @include flexCon(290px, auto, flex-start, space-between, 40px);
    position: relative;
    align-items: flex-start;
  }
  .search-con {
    @include flexCon(290px, 50px, center, space-between, 40px);
    position: relative;
    margin-top: 20px;
    input {
      @include wd(220px, 30px);
      background: rgba(255, 255, 255, 1);
      border-radius: 3px;
      font-size: 14px;
      padding-left: 8px;
      border: 1px solid rgba(223, 223, 223, 1);
    }
    .mainKey {
      width: 170px;
      height: 30px;
      border-radius: 2px;
      margin-left: 10px;
      border: 1px solid rgba(224, 225, 232, 1);
    }
    .add-tag {
      @include wd(auto, 30px);
      border-radius: 2px;
      font-size: 14px;
      text-align: center;
      line-height: 30px;
      padding: 0 10px;
      border: 1px solid rgba(224, 225, 232, 1);
      cursor: pointer;
    }
  }
  .addcon {
    @include flexCon(320px, 50px, center, space-between, 32px);
    position: relative;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 20px;
    input {
      @include wd(225px, 30px);
      background: rgba(255, 255, 255, 1);
      border-radius: 3px;
      font-size: 14px;
      padding-left: 8px;
      border: 1px solid rgba(223, 223, 223, 1);
    }
    .search-itemtag {
      width: auto;
      height: 20px;
      padding: 2px 4px;
      background: rgba(243, 244, 246, 1);
      border-radius: 2px;
      margin-left: 6px;
    }
  }
}
</style>
